package com.jiangruan.javaproject;

import com.jiangruan.javaproject.address.Addresss;
import com.jiangruan.javaproject.request.service.GetBestBlockHashService;
import com.jiangruan.javaproject.request.service.GetblockcountService;
import com.jiangruan.javaproject.request.service.HotVideoService;
import com.jiangruan.javaproject.request.service.NewsHeadService;

import java.security.KeyPair;

import java.util.Scanner;

/**
 * @author:liufukai
 * @email:1324963242@qq.com
 * @desc:该类是java项目的主函数的类是程序的入口
 * @datatime:2021/12/522:26
 */
public class Main {
    public static void main(String[] args) {
//        System.out.println("hello world");
//        HotVideoService hotVideoService = new HotVideoService();
//
//        GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
//        String bestBlockHash = getBestBlockHashService.getBestBlockHash();
//        System.out.println(bestBlockHash);


        Main test = new Main();
        test.run();
    }

    public void run() {
        System.out.println("=====java期末大作业=====");
        System.out.println("本系统实现了以下功能：");
        while (true){
            menu();
        }
    }

    public void menu() {
        System.out.println("1.热门视频数据 2.头条新闻数据 3.比特币客户端通信并获取最高位区块哈希 " +
                "4.比特币客户端通信并获取区块数量 5.比特币生成的新的地址并检验地址是否规范(ture为规范,反之不规范) 0.退出");
        System.out.println("请输入你的选择");
        Scanner scanner = new Scanner(System.in);
        String user_input = scanner.next();
        int num = Integer.parseInt(user_input);
        switch (num) {
            case 1:
                HotVideoService hotVideoService = new HotVideoService();
                hotVideoService.getHotVideo();
                break;
            case 2:
                NewsHeadService newsHeadService = new NewsHeadService();
                 newsHeadService.getNewsHead();
                break;
            case 3:
                GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
                getBestBlockHashService.getBestBlockHash();
                break;
            case 4:
                GetblockcountService getblockcount = new GetblockcountService();
                getblockcount.getblockcount();
                break;

            case 5:
                Addresss addresss = new Addresss();
                KeyPair keyPair = addresss.generateKey();
                String s = addresss.newAddress(keyPair);
                System.out.println(addresss.isValidata(s));
                System.out.println("新地址是:"+s);
            break;
            case 0:
                System.exit(0);
                break;
                default:
                    System.out.println("输入有误，不支持去该功能");
        }
    }
}
